package com.hy.admin.security.oauth;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.CompositeTokenGranter;
import org.springframework.security.oauth2.provider.TokenGranter;
import org.springframework.security.oauth2.provider.TokenRequest;

public class AuthorizationServerCustomGrantParserTests {
	
	private static String RESOURCE_NAME = "authorization-server-custom-grant.xml";
	
	private ConfigurableApplicationContext context;
	
	
	public AuthorizationServerCustomGrantParserTests() {
		context = new GenericXmlApplicationContext(getClass(), RESOURCE_NAME);
	}
	
	
	public static class CustomTestTokenGranter implements TokenGranter {
		
		public CustomTestTokenGranter() {}

		public OAuth2AccessToken grant(String grantType,
				TokenRequest tokenRequest) {
			if (grantType.equals("password")) {
				return new DefaultOAuth2AccessToken("test");
			}
			return null;
		}
		
	}

}
